package org.anyin.gitee.cloud.center.upms.repository;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.anyin.gitee.cloud.center.upms.mapper.SysMenuMapper;
import org.anyin.gitee.cloud.center.upms.model.SysMenu;
import org.anyin.gitee.cloud.center.upms.model.ext.SysMenuExt;
import org.anyin.gitee.cloud.lib.core.web.BaseRepository;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class SysMenuRepository extends BaseRepository<SysMenuMapper, SysMenu> {

    public Page<SysMenuExt> page(Page<SysMenuExt> page, SysMenuExt entity){
        List<SysMenuExt> list = baseMapper.page(page, entity);
        page.setRecords(list);
        return page;
    }

    public List<SysMenu> all(){
        return baseMapper.selectList(new QueryWrapper<>());
    }

    public SysMenu getByMenuCode(String menuCode){
        return baseMapper.getByMenuCode(menuCode);
    }

    public List<SysMenu> getByParentMenuCode(String parentMenuCode){
        return baseMapper.getByParentMenuCode(parentMenuCode);
    }

    public SysMenu getByPermission(String permission){
        return baseMapper.getByPermission(permission);
    }
}
